<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 未捕获异常
        // async function f(){
        //     let data = await new Promise((resolve, reject) => {
        //         setTimeout(() => {
        //             reject('123');
        //         }, 2000);
        //     });

        //     // reject后，后续代码无法执行
        //     console.log('done');
        // }

        // 捕获异常
        async function f(){
            try {
                let data = await new Promise((resolve, reject) => {
                    // setTimeout(() => {
                    //     reject('123');
                    // }, 2000);
                    throw new Error('1234');
                });

                // reject后，后续代码无法执行
                console.log('done');
            } catch (error) {
                console.log('异常：', error);
            }
        }
        
    </script>
</body>
</html>